package com.example.sqlist03;

import android.content.ContentValues;
import android.content.Context;
import android.database.ContentObservable;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class mySQList extends SQLiteOpenHelper {
    public mySQList(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //第一步创建表
        String lie="create table student(_id integer primary key autoincrement,name text not null,age integer)";
        db.execSQL(lie);
        //contenvalues只能存储基本类型的数据，像string，int之类的，不能存储对象这种东西，而HashTable却可以存储对象
        ContentValues contentValues=new ContentValues();
        contentValues.put("name","李华");
        contentValues.put("age",18);
        db.insert("student",null,contentValues);//insert（插入）
        contentValues.put("name","小明");
        contentValues.put("age",20);
        db.insert("student",null,contentValues);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
